import request from '@/utils/request'

/**
 * 获取文章分类
 * @returns Promise
 */
export const articleGetChannelService = () => request.get('/my/cate/list')

/**
 * 添加分类
 * @param {*} data
 * @returns Promise
 */
export const articleAddChannelService = (data) => request.post('/my/cate/add', data)

/**
 * 更新分类
 * @param {*} data
 * @returns
 */
export const articleUpdateChannelService = (data) => request.put('/my/cate/info', data)

/**
 * 删除分类
 * @param {*} params
 * @returns Promise
 */
export const articleDeleteChannelService = (id) =>
  request.delete('/my/cate/del', { params: { id } })

/**
 * 获取文章列表
 * @param {*} params
 * @returns
 */
export const articleGetListService = (params) => request.get('/my/article/list', { params })

/**
 * 发布文章
 * @param {*} data FormData 对象
 * @returns
 */
export const articlePublishService = (data) => request.post('/my/article/add', data)

/**
 * 获取文章详情
 * @param {*} id 文章 id
 * @returns
 */
export const articleGetInfoService = (id) =>
  request.get('/my/article/info', {
    params: { id },
  })

/**
 * 更新文章详情
 * @param {*} data
 * @returns
 */
export const articleUpdateArticleService = (data) => request.put('/my/article/info', data)

/**
 * 删除文章详情
 * @param {*} id
 * @returns
 */
export const articleDelArticleService = (id) =>
  request.delete('/my/article/info', { params: { id } })
